package com.zhou.common.mybatis.template.shiro.controller;


import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.zhou.common.lib.model.Response;
import com.zhou.common.mybatis.template.shiro.ao.SysUserOnlineAo;
import com.zhou.common.mybatis.template.shiro.entity.SysUserOnline;
import com.zhou.common.mybatis.template.shiro.enums.OnlineStatus;
import com.zhou.common.mybatis.template.shiro.service.ISysUserOnlineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 在线用户记录 前端控制器
 * </p>
 *
 * @author zxf
 * @since 2023-02-21
 */
@ApiSupport(order = 1)
@Api(tags = {"在线用户记录"})
@RestController
@RequestMapping("/sys-user-online")
public class SysUserOnlineController {

    @Autowired
    private ISysUserOnlineService userOnlineService;

    @RequiresRoles("test1")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询接口")
    @PostMapping("/query")
    public Response<List<SysUserOnline>> query(@Valid @RequestBody SysUserOnlineAo userOnline) {
        List<OnlineStatus> statuses = userOnline.getStatuses();
        List<SysUserOnline> list = userOnlineService.list();
        return Response.success(list);
    }
}
